<?php

/**
 * This is the model class for table "site_administrator_group".
 *
 * The followings are the available columns in table 'site_administrator_group':
 * @property string $administrator_group_id
 * @property string $administrator_group_title
 * @property string $administrator_group_type
 * @property string $administrator_group_is_active
 *
 * The followings are the available model relations:
 * @property SiteAdministrator[] $siteAdministrators
 * @property SiteAdministratorPrivilege[] $siteAdministratorPrivileges
 */
class site_administrator_group extends CActiveRecord {

    /**
     * Returns the static model of the specified AR class.
     * @return site_administrator_group the static model class
     */
    public static function model($className=__CLASS__) {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName() {
        return 'site_administrator_group';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules() {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('administrator_group_title', 'required'),
            array('administrator_group_title', 'length', 'max' => 50),
            array('administrator_group_type', 'length', 'max' => 13),
            array('administrator_group_is_active', 'length', 'max' => 1),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('administrator_group_id, administrator_group_title, administrator_group_type, administrator_group_is_active', 'safe', 'on' => 'search'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations() {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
            'rel_administrator_group_to_administrator' => array(self::HAS_MANY, 'site_administrator', 'administrator_administrator_group_id'),
            'rel_administrator_group_to_administrator_privilege' => array(self::HAS_MANY, 'site_administrator_privilege', 'administrator_privilege_administrator_group_id'),
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels() {
        return array(
            'administrator_group_id' => 'Group',
            'administrator_group_title' => 'Group',
            'administrator_group_type' => 'Group Type',
            'administrator_group_is_active' => 'Is Active',
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search() {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria = new CDbCriteria;

        $criteria->compare('administrator_group_id', $this->administrator_group_id, true);
        $criteria->compare('administrator_group_title', $this->administrator_group_title, true);
        $criteria->compare('administrator_group_type', $this->administrator_group_type, true);
        $criteria->compare('administrator_group_is_active', $this->administrator_group_is_active, true);

        return new CActiveDataProvider($this, array(
            'criteria' => $criteria,
        ));
    }

}